<head>
    <meta charset="utf8">
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>

<body>
    <div id="myapp">
        <div>{{input_text}}</div>
        <my-input v-model="input_text"></my-input>
    </div>
</body>
<script>
    const app = Vue.createApp({
        data() {
            return {
                input_text: "123",
            }
        },
    });
    const input_component = {
        props: ["modelValue"],
        methods: {
            action(event) {
                this.$emit('update:modelValue', event.target.value);
            }
        },
        // v-on modelValue  @ 外部传递 update:modelValue(new_value)
        template: `<div><span>输入框: </span><input :value="modelValue" @input="action"></div>`
    }
    app.component("my-input", input_component);
    app.mount("#myapp")
</script>